package com.g001.model.GUI;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;
import org.newdawn.slick.state.StateBasedGame;

import com.g001.enums.MessagePositionType;
import com.g001.util.CachedResourceLoader;

public class BattleZone {

	private Image image;
	private Vector2f position;
	private MessagePositionType messagePositionType;
	
	public final static int WIDTH = 200;
	public final static int HEIGTH = 200;
	
	
	public BattleZone(final String path, MessagePositionType messagePositionType) throws SlickException {
		this.messagePositionType = messagePositionType;
		image = CachedResourceLoader.getInstance().getImage(path);
	}
	
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
		if(position!=null)
		g.drawImage(image,position.x, position.y);
	}

	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
		switch(messagePositionType){
		case CENTER : position = new Vector2f((container.getWidth() - image.getWidth())/2, (container.getHeight()-image.getHeight())/2);break;
		case LEFT : position = new Vector2f(0 , 200 );break;
		case RIGHT : position = new Vector2f(container.getWidth() - WIDTH - 10, 200 );break;
		case BOTTOM : position = new Vector2f((container.getWidth() - WIDTH)/2, HEIGTH -100);break;
		default :
			position = new Vector2f(0,0);break;
		}
	}
}
